package com.tacademy.jmtwitter;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

import android.text.format.DateUtils;
import android.util.Log;

public class Status {
	public Status() {
		super();
	}

	public Status(String text, String create_at, User user) {
		super();
		this.text = text;
		this.create_at = create_at;
		this.user = user;
	}

	public Status(String text, String create_at, String id, User user) {
		super();
		this.text = text;
		this.create_at = create_at;
		this.id = id;
		this.user = user;
	}

	private String text, create_at;
	String id;
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	User user;
	//이건 항상 static  객체 만드는데 엄청 느려짐 
	static SimpleDateFormat sFormat = new SimpleDateFormat("EEE LLL dd kk:mm:ss Z yyyy", Locale.US);// TODO SimpleDateFormat 문서보고
	String getFormattedCreatedAt(){
		// Tue Jan 03 02:10:17 +0000 2012
		Date date;
		String s=null;
		try {
			//1 long 값으로 변환
			date = sFormat.parse(create_at);
			long timeMillis = date.getTime();
			
			//2. Format
			//TODO 문서보고 하기
			s = DateUtils.getRelativeTimeSpanString(timeMillis).toString();
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			Log.e("ta","Parse Exception");
		}
		
		return s;
	}
	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	public String getCreate_at() {
		
		return getFormattedCreatedAt();
	}

	public void setCreate_at(String create_at) {
		this.create_at = create_at;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

}
